/**********************************************************
* @ File name -> gun.h
* @ Version   -> V1.0
* @ Date      -> 20160718
* @ Brief     -> 充电枪控制相关函数头文件

 V1.*
* @ Revise    ->
**********************************************************/

#ifndef __MOD_GUN_H__
#define __MOD_GUN_H__

#include "typedef.h"

/**********************************************************
                         定义接口
**********************************************************/
#define LOCK_LARGE_TEM 100  //电磁锁温度监控保护值


//充电枪电磁锁继电器管脚 PE4 PE5

//充电枪cc管脚 PE13
enum {
    DRV_GUN_CC_STATE_GUN_ON,  //充电枪连接车辆端
    DRV_GUN_CC_STATE_GUN_OFF, //充电枪未连接车辆端
};
enum {
    LOCK_TEM_INSIDE = 0,//电磁锁温度正常
    LOCK_TEM_OVER, //电磁锁超温
};

enum {
    DRV_GUN_CP_12V = 0,
    DRV_GUN_CP_9V,
    DRV_GUN_CP_6V,
    DRV_GUN_CP_ERR,
};

enum RelayAlarmState{
    RELAY_ALARM_NULL = 0,
    RELAY_ALARM_STUCK,   //继电器粘连
    RELAY_ALARM_UNCLOSE, //继电器不能闭合
};

enum GunLinkState{
    DRV_GUN_STATE_FREE = 0, //充电枪空闲  cc 12
    DRV_GUN_STATE_INDEV, //充电枪连接设备 cc 0 && cp 12v
    DRV_GUN_STATE_INCAR, //充电枪连接汽车 cc 0 && cp 9v
    DRV_GUN_STATE_READY, //汽车准备好充电 cc 0 && cp 6v
    DRV_GUN_STATE_ERR,
};

enum GunPwmState{
    DRV_GUN_PWM_NULL = 0,
    DRV_GUN_PWM_OFF,
    DRV_GUN_PWM_ON,
};

int32_t gun_init(void);
uint8_t gun_get_state(uint8_t gunid);
uint32_t gun_get_cp_value(void);
int32_t gun_start_charge(uint8_t gunid);
int32_t gun_stop_charge(uint8_t gunid);
uint8_t gun_get_relay_alarm(uint8_t gunid);
uint8_t gun_get_relay_state(uint8_t gunid);

#endif

